 package net.go176.backpack.config;
 
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.logging.Level;
 import org.bukkit.configuration.Configuration;
 import org.bukkit.configuration.file.FileConfiguration;
 import org.bukkit.configuration.file.YamlConfiguration;
 import org.bukkit.plugin.Plugin;
 
 public class Config
 {
   protected Plugin p;
   private final String file;
   private final String folder;
   private File cfgFile = null;
  private FileConfiguration cfg = null;
   
   public Config(Plugin plugin, String file) {
     this(plugin, "", file);
   }
   
   public Config(Plugin plugin, String folder, String file) {
    this.p = plugin;
     this.folder = folder;
     this.file = file;
   }
   
   public String getFileName() {
     return this.file;
   }
   
   public String getFolderName() {
     return this.folder;
   }
   
   public FileConfiguration getConfig() {
     if (this.cfg == null)
       reloadConfig(); 
     return this.cfg;
   }
   
   public void reloadConfig() {
     if (this.cfgFile == null)
       this.cfgFile = new File(this.p.getDataFolder() + "/" + this.folder, this.file); 
     try {
       FileInputStream configStream = new FileInputStream(this.cfgFile);
       try {
         this.cfg = (FileConfiguration)YamlConfiguration.loadConfiguration(new InputStreamReader(configStream, "UTF8"));
       } catch (Throwable t) {
         this.cfg = (FileConfiguration)YamlConfiguration.loadConfiguration(configStream);
       } 
     } catch (FileNotFoundException e) {
       this.cfg = (FileConfiguration)new YamlConfiguration();
     } 
     InputStream defConfigStream = this.p.getResource(getFilePath());
     if (defConfigStream != null) {
       YamlConfiguration defConfig;
       try {
         defConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, "UTF8"));
       } catch (Throwable t) {
         defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
       } 
       this.cfg.setDefaults((Configuration)defConfig);
     } 
     this.cfg.options().copyHeader();
   }
   
   public void saveConfig() {
     if (this.cfg == null || this.cfgFile == null) {
       return;
     }
     try {
       getConfig().save(this.cfgFile);
     } catch (IOException ex) {
       this.p.getLogger().log(Level.SEVERE, "Could not save config to " + this.cfgFile, ex);
     } 
   }
   
   public void saveDefaultConfig() {
     if (this.cfgFile == null)
       this.cfgFile = new File(this.p.getDataFolder() + "/" + this.folder, this.file); 
     if (!this.cfgFile.exists())
       this.p.saveResource(getFilePath(), false); 
   }
   
   public String getFilePath() {
     String folder = this.folder;
     if (folder.length() > 0)
       folder = String.valueOf(folder) + "/"; 
     return String.valueOf(folder) + this.file;
   }
 }


/* Location:              D:\User\Xuan\Downloads\MyBackpack1.2.5.jar!\net\saralab\mybackpack\config\Config.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.1.3
 */